Revert "Add ExecutionPlan::apply_expressions() (#20337)" - #22437
Merged
Conversation
This reverts commit a5f490e. # Conflicts: # datafusion/core/tests/physical_optimizer/filter_pushdown.rs # datafusion/datasource-json/src/source.rs # datafusion/datasource/src/file_scan_config/mod.rs # datafusion/datasource/src/source.rs # datafusion/ffi/src/execution_plan.rs # datafusion/physical-optimizer/src/ensure_coop.rs # datafusion/physical-plan/src/execution_plan.rs # datafusion/physical-plan/src/union.rs # docs/source/library-user-guide/custom-table-providers.md # docs/source/library-user-guide/upgrading/54.0.0.md
adriangb
approved these changes
May 21, 2026
alamb
marked this pull request as ready for review
May 21, 2026 17:48
Contributor
Author
|
Once we merge this I will backport it to branch-54 as well |
This was referenced May 21, 2026
Contributor
Author
zhuqi-lucas
added a commit
to zhuqi-lucas/arrow-datafusion
that referenced
this pull request
May 23, 2026
… trait method The two MockReqExec impls in this test file override ExecutionPlan::apply_expressions, added when apache#20337 introduced the trait method. Upstream apache#22437 reverted that addition, so the overrides now reference a trait method that no longer exists and the test crate fails to compile after rebasing onto main. Removing both override blocks restores the trait-default behavior (no-op) used before apache#20337.
MassivePizza
pushed a commit
to massive-com/arrow-datafusion
that referenced
this pull request
Jul 15, 2026
…20337)" (apache#22437) (apache#22445) - Backports apache#22437 from @alamb to the branch-54 line This PR cherry-picks the revert of `ExecutionPlan::apply_expressions()` (apache#20337) onto `branch-54` so that DataFusion 54.0 does not ship the new public API.
MassivePizza
pushed a commit
to massive-com/arrow-datafusion
that referenced
this pull request
Jul 15, 2026
…20337)" (apache#22437) (apache#22445) - Backports apache#22437 from @alamb to the branch-54 line This PR cherry-picks the revert of `ExecutionPlan::apply_expressions()` (apache#20337) onto `branch-54` so that DataFusion 54.0 does not ship the new public API.
jayshrivastava
added a commit
to jayshrivastava/datafusion
that referenced
this pull request
Jul 30, 2026
pull Bot
pushed a commit
to Stars1233/datafusion
that referenced
this pull request
Aug 10, 2026
…he#22437) (apache#24018) ## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123. --> - Informs: apache#23814 - Informs: datafusion-contrib/datafusion-distributed#584 This change does not close the above issues because it does not implement a way to tell if a node is a producer dynamic filters. ## Rationale for this change See apache#23814 and datafusion-contrib/datafusion-distributed#553. To send dynamic filter updates across the network, there needs to be a way to get access to `PhysicalExpr` from `ExecutionPlan`. As discussed in apache#23814, the cleanest way to do this is to add `ExecutionPlan::apply_expressions`, which mirrors a similar method for logical plan nodes. ## What changes are included in this PR? There's 3 commits in this PR: Firstly, commit 1 re-applies the changes in apache#20337 (reverted in apache#22437). Some of the reasons for why the original PR was reverted include (a) `apply_expressions` is too complicated to implement and there's no concrete need to justify this complexity (b) there was no usage of `apply_expressions` inside this repo To address (a) - justification for adding this method is provided in apache#23814 - commit 2 in this PR adds helper methods `apply_expression_roots` and `apply_no_expressions` which abstract away the `TreeNodeRecursion` complexity from implementors. Now, `apply_expressions` very trivial to implement ex. ```rust fn apply_expressions( &self, f: &mut dyn FnMut(&Arc<dyn PhysicalExpr>) -> Result<TreeNodeRecursion>, ) -> Result<TreeNodeRecursion> { apply_expression_roots([&self.predicate_1], f) apply_expression_roots([&self.predicate_2], f) apply_expression_roots([&self.other_expression], f) } ``` - the method traverses over `&Arc<dyn PhysicalExpr>` rather than `&dyn PhysicalExpr` to reduce complexity around lifetimes To address (b): - commit 3 adds a usage of `apply_expressions` in `physical-plan/src/aggregates/mod.rs`. Previously, there was a hack that checked if a filter was pushed down using `Arc::strong_count(dyn_filter) > 1`. Now it uses `apply_expressions` - similarly, commit 4 removes `is_used` from dynamic filters which used to check Arc references counts to see if a filter was pushed down. Now, the hash join uses `apply_expressions` to find pushed down filters. ## Are these changes tested? Yes. ## Are there any user-facing changes? There's a new mandatory method `ExecutionPlan::apply_expressions()`. See the upgrading guide and documentation for details. --------- Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
ExecutionPlan::apply_expressions()#20337Rationale for this change
ExecutionPlan::apply_expressions()was added in #20337 with no default implementation, forcing every customExecutionPlan,FileSource, andDataSourceimplementor to add the method as part of upgrading to DataFusion 54.As discussed on #22415, per @LiaCastaneda and @adriangb the method is not yet called from anywhere in DataFusion and the originally intended use (dynamic-filter discovery/serialization for distributed scenarios) is blocked on other in-progress work (#20009, #21350).
The combined effect on downstream users is a required code change with no immediate benefit, and ambiguity about what a "correct" implementation even means today (e.g. is returning
Ok(TreeNodeRecursion::Continue)is safe right now but becomes incorrect as soon as the method starts being used by an optimizer pass?.The plan agreed in the discussion is to remove the API from the 54.0 release and re-add it together with the concrete consumer that needs it. cc @adriangb @LiaCastaneda @milenkovicm.
What changes are included in this PR?
git revert -m 1of the merge commit, with the following manual conflict resolutions and follow-ups:Are these changes tested?
By CI
Are there any user-facing changes?
Yes -- this removes the new public API:
ExecutionPlan::apply_expressionsFileSource::apply_expressionsDataSource::apply_expressionsThese were only added in 54 and are not yet released. Custom implementors no longer need to implement these methods.